package com.memo.model;

import android.app.Activity;
import android.content.Context;
import android.os.Build;
import android.view.MenuItem;
import android.widget.ImageView;
import android.widget.PopupMenu;
import android.widget.Toast;

import androidx.annotation.RequiresApi;

import com.memo.R;

public class homeonemenu_model {
    Activity activity;
    public homeonemenu_model(Activity activity){
        this.activity=activity;
    }
    @RequiresApi(api = Build.VERSION_CODES.Q)
    public void OnCreateMenu(ImageView homeone_menu){//创建菜单事件
        PopupMenu popupMenu = new PopupMenu(activity, homeone_menu);
        popupMenu.getMenuInflater().inflate(R.menu.homeone_menu,popupMenu.getMenu());
        popupMenu.setForceShowIcon(true);
        popupMenu.show();
        popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                switch (item.getItemId()){
                    case R.id.recycle:
                        Toast.makeText(activity,"回收站被点击",Toast.LENGTH_LONG).show();
                        return true;
                    case R.id.feedback:
                        return true;
                }
                return false;
            }
        });

    }
}
